package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.AccountGroupMapper;
import com.molichuxing.services.infrastructure.dto.response.response.AccountGroupDto;
import com.molichuxing.services.infrastructure.service.AccountGroupService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("accountGroupService")
public class AccountGroupServiceImpl implements AccountGroupService {

    @Resource
    private AccountGroupMapper accountGroupMapper;

    @Override
    public List<AccountGroupDto> getAccountGroupListByParam(Map<String, Object> param) {
        return Convert.toAccountGroupDtoList(accountGroupMapper.getAccountGroupListByParam(param));
    }

    @Override
    public int createBatchAccountGroup(AccountGroupDto dto) {
        if (dto != null) {
           return accountGroupMapper.createAccountGroup(Convert.toAccountGroupBean(dto));
        }
        return 0;
    }

    @Override
    public int deleteByAccountId(int accountId) {
        if (accountId > 0) {
            return accountGroupMapper.deleteByAccountId(accountId);
        }
        return 0;
    }

    @Override
    public int deleteByParam(Map<String, Object> param) {
        return accountGroupMapper.deleteByParam(param);
    }
}
